package com.shaowc.gs.spring.beans;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;

/**
 * bean factory demo
 * created by shaowenchao
 */
public class BeanFactocyDemo {

    public static void main(String[] args) {
        ClassPathResource res=new ClassPathResource("beans.xml");
        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
        reader.loadBeanDefinitions(res);
        HelloWorld helloWorld =(HelloWorld) factory.getBean("helloWorld");
        helloWorld.echo("hello world");
    }

}
